package com.mt.api.modules.controller;

import com.mt.api.modules.domain.bo.AppSuggestPageBo;
import com.mt.api.modules.service.AppSuggestService;
import com.mt.api.util.ParamsValid;
import com.mt.common.response.WebResponse;
import com.mt.common.response.WebResponseUtils;
import com.mt.api.modules.domain.bo.AppSuggestAddBo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import com.mt.log.annotation.Log;
import org.springframework.web.bind.annotation.*;


/**
 * @author plover
 * @date 2020-07-06
 **/
@RestController
@RequiredArgsConstructor
@Api(tags = "意见反馈管理")
@RequestMapping("/app/suggest")
public class AppSuggestController {

    private final AppSuggestService appSuggestService;


    @GetMapping("/page")
    @ApiOperation(value = "", notes = "意见反馈分页查询接口", httpMethod = "GET")
    public WebResponse getSuggestPage(AppSuggestPageBo suggestPageBo) {
        ParamsValid valid = new ParamsValid();
        if (!valid.isValid()) {
            return WebResponseUtils.errorParam(valid.getMsg());
        }
        return appSuggestService.getSuggestPage(suggestPageBo);
    }

    @PostMapping("/add")
    @Log("意见反馈新增")
    @ApiOperation(value = "", notes = "意见反馈提交接口", httpMethod = "POST")
    public WebResponse addSuggest(@RequestBody AppSuggestAddBo appSuggestAddBo) {
        ParamsValid valid = new ParamsValid();
        valid.validNotNull("请输入问题类型", appSuggestAddBo.getType())
                .validNotNull("请输入内容", appSuggestAddBo.getContent());
        if (!valid.isValid()) {
            return WebResponseUtils.errorParam(valid.getMsg());
        }
        return appSuggestService.addSuggest(appSuggestAddBo);
    }
}